<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ include file="/include/taglibs.jsp" %>
<html>
<head>
    <%@include file="/include/header.html" %>
    <%--<link rel="stylesheet" href="${ctx}/libjs/plugins/h-ui/css/H-ui.min.css">--%>
    <link rel="stylesheet" href="${ctx}/libjs/plugins/h-ui/css/H-ui.admin.css">
    <link rel="stylesheet" href="${ctx}/libjs/plugins/h-ui/style.css">
    <script type="text/javascript"
            src="https://webapi.amap.com/maps?v=1.3&key=e392de55be62b195115e32b97043a1bd&plugin=AMap.Autocomplete,AMap.PlaceSearch"></script>
    <script type="text/javascript" src="${ctx}/appjs/member/member/membergain.js"></script>
    <style>
        th,td {
            border-right: 1px solid #eee;
        }
        .rowAddDelBtn {
            line-height: 19.5px;
            margin: 2px;
            color: white;
            width: 20px;
            height: 20px;
            border-radius: 10px;
            border: none;
            font-size: 15px;
            display: inline-block;
        }
        #bableBody tr:first-child .rowDelBtn {
            display: none;
        }
        #chargeHandselBody tr:first-child .rowDelBtn {
            display: none;
        }
    </style>
</head>

<script type="text/javascript">
    $('#topLink', window.parent.document).html(function (i, origText) {
        return '<ol class="breadcrumb">' +
            '<li class="breadcrumb-item">' +
            '<a href="">会员管理</a>' +
            '</li>' +
            '<li class="breadcrumb-item">' +
            '<a>会员权益</a>' +
            '</li>' +
            '<li class="breadcrumb-item">' +
            '<strong>新增会员权益</strong>' +
            '</li>' +
            '<li class="breadcrumb-item">' +
            '<a href="javascript:window.history.back()"><i class="fa fa-times"></i> 返回</a>' +
            '</li>' +
            '</ol>';
    });
</script>

<body class="gray-bg">
<div class="wrapper wrapper-content ">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <div class="columns pull-left">
                        <h5 class="font-bold">新增会员权益</h5>
                    </div>
                    <div class="ibox-tools">
                        <a class="close-link">
                            <i class="fa fa-times"></i>
                        </a>
                    </div>
                </div>

                <div class="ibox-content">
                    <form class="form-horizontal m-t" id="frmMemberGain">
                        <div class="form-group row">
                            <label class="col-sm-3 col-form-label text-right">权益名称：</label>
                            <div class="col-sm-8">
                                <input type="text" class="form-control" id="gainName" name="gainName">
                            </div>
                        </div>
                        <div class="form-group row">
                            <label class="col-sm-3 col-form-label text-right">所属会员等级：</label>
                            <div class="col-sm-8">
                                <select id="memberLevel" name="memberLevel" class="form-control" placeholder="请选择所属会员等级">
                                    <c:forEach items="${parLevels}" var="bean">
                                        <option value="${bean.memberLevel}">${bean.memberLevel}
                                        </option>
                                    </c:forEach>
                                </select>
                            </div>
                        </div>
                        <div class="form-group row">
                            <label class="col-sm-3 col-form-label text-right">会员子等级：</label>
                            <div class="col-sm-8">
                                <select id="levelSub" name="levelSub" class="form-control" placeholder="请选择会员子等级">
                                    <c:forEach items="${levels}" var="bean">
                                        <option value="${bean.levelSub}">${bean.levelSub}
                                        </option>
                                    </c:forEach>
                                </select>
                            </div>
                        </div>
                        <div class="form-group row">
                            <label class="col-sm-3 col-form-label text-right">会员标识图标：</label>
                            <div class="col-sm-8">
                                <div>
                                    <img id="gainLogo" src="${ctx}/statics/img/upload-img.png"
                                         style="position: relative" width="155px" height="120px">
                                    <input type="file" id="file1" name="file1"/>
                                </div>
                            </div>
                        </div>
                        <div class="form-group row">
                            <label class="col-sm-3 col-form-label text-right">权益类型：</label>
                            <div class="col-sm-4">
                                <input type="radio"   name="gainType" value="0" checked onchange="typeChange(this,'0')">充值消费折扣
                            </div>
                        </div>
                        <div class="form-group row">
                            <label class="col-sm-3 col-form-label text-right"></label>
                            <div class="col-sm-4">
                                <input type="radio"  name="gainType" value="1" onchange="typeChange(this,'1')">充值赠送金额
                            </div>
                        </div>
                        <div class="form-group row">
                            <label class="col-sm-3 col-form-label text-right"></label>
                            <div class="col-sm-4">
                                <input type="radio"  name="gainType" value="2" onchange="typeChange(this,'2')">生日礼遇
                            </div>
                        </div>
                        <%--<div class="form-group row" id="consumeEnumBox" style="display:none;">
                            <input type="checkbox"  id="consumeEnum" name="consumeEnum" value="1" style="margin-left: 212px;">充值消费折扣
                        </div>
                        <div class="form-group row" id="consumeTableId">
                            <div id="tableId" class="col-sm-8  text-left" style="padding: 30px; margin: 0 auto;" >
                                <table id="bableId" class="col-sm-8 col-form-label text-left" style="color: gray;border-top: 1px solid #e5e6e7;border-left: 1px solid #e5e6e7; font-size: 14px ;line-height: 30px;">
                                    <thead style="display: block;background-color: #b4dbed;">
                                        <th style="min-width: 55px; text-align: center;"><i class="fa fa-gear"></i></th>
                                        <th style="min-width: 100px; text-align: center;">档位</th>
                                        <th style="min-width: 200px; text-align: center;">充值金额</th>
                                        <th style="min-width: 200px; text-align: center;">消费折扣</th>
                                    </thead>
                                    <tbody id="bableBody" style="display: block;" >
                                        <tr>
                                            <td style="min-width: 55px; text-align: center;">
                                                <div class="rowAddDelBtn rowAddBtn" style="background-color: #ff5581;font-size: 15px !important;">+</div>
                                                <div class="rowAddDelBtn rowDelBtn" style="background-color: greenyellow;">-</div>
                                            </td>
                                            <td style="min-width: 100px; text-align: center;">1</td>
                                            <td style="min-width: 200px; text-align: center;">
                                                <input type="text" name="rechargeAmount" id="' + rechargeAmount + '" maxlength="100" style="width: 90%; height: 22px; border: 1px solid #e6e6e6;"/>
                                            </td>
                                            <td style="min-width: 200px; text-align: center;">
                                                <input type="text" name="discountAmount" id="' + discountAmount + '" maxlength="100" style="width: 90%; height: 22px; border: 1px solid #e6e6e6;"/>
                                            </td>
                                        </tr>
                                    </tbody>
                                    <!--循环代码加载此处-->
                                </table>
                            </div>
                        </div>--%>
<%--
                        <div class="form-group row" id="consumeInputId">
                            <label class="col-sm-3 col-form-label text-right">退款再充值规则：</label>
                            <div class="col-sm-8 col-sm-8" >
                                <span class="col-sm-2  col-form-label text-left" >退款</span>
                                <input type="text" id="refundCountTarget" name="refundCountTarget"  style="width: 10%; border-bottom: 2px solid #666;">
                                <span class="col-sm-2  col-form-label text-left">次后,再充值消费无折扣</span>
                            </div>
                        </div>--%>
                        <%--<div class="form-group row" id="handselEnumBox" style="display:none;">
                            <input type="checkbox"  id="handselEnum" name="handselEnum" value="1" style="margin-left: 212px;">充值赠送权益金
                        </div>
                        <div id="handselTableId" class="col-sm-8 col-form-label text-left" style="padding-top: 30px; margin: 0 auto; display:none;"  >
&lt;%&ndash;                            <input type="button" onclick="addMemberGain.addChargeTb('chargeHandselId')" value="添加" style="margin-left: 300px;"/>&ndash;%&gt;
&lt;%&ndash;                            <input type="button" onclick="deleteTb('chargeTableId')" value="删除" />&ndash;%&gt;
                            <table id="chargeHandselId" class="col-sm-3 col-form-label text-left" style="color: gray;border-top: 1px solid #e5e6e7;border-left: 1px solid #e5e6e7; font-size: 14px ;line-height: 30px;">
                                <thead style="display: block;background-color: #b4dbed;">
                                    <th style="min-width: 55px; text-align: center;"><i class="fa fa-gear"></i></th>
                                    <th style="min-width: 100px; text-align: center;">档位</th>
                                    <th style="min-width: 200px; text-align: center;">充值金额</th>
                                    <th style="min-width: 200px; text-align: center;">权益金(赠送金额)</th>
                                    <th style="min-width: 200px; text-align: center;">累计消费满N元可用</th>
                                </thead>
                                <tbody id="chargeHandselBody" style="display: block;" >
                                    <tr>
                                        <td style="min-width: 55px; text-align: center;">
                                            <div class="rowAddDelBtn rowAddBtn" style="background-color: #ff5581;font-size: 15px !important;">+</div>
                                            <div class="rowAddDelBtn rowDelBtn" style="background-color: greenyellow;">-</div>
                                        </td>
                                        <td style="min-width: 100px; text-align: center;">1</td>
                                        <td style="min-width: 200px; text-align: center;"><input type="text" name="rechargeAmount" id="' + rechargeAmount + '1" maxlength="100" style="width: 90%; height: 22px; border: 1px solid #e6e6e6;"/></td>
                                        <td style="min-width: 200px; text-align: center;"><input type="text" name="gainAmount" id="' + gainAmount + '" maxlength="100" style="width: 90%; height: 22px; border: 1px solid #e6e6e6;"/></td>
                                        <td style="min-width: 200px; text-align: center;"><input type="text" name="consumeUseAmount" id="' + consumeUseAmount + '" maxlength="100" style="width: 90%; height: 22px; border: 1px solid #e6e6e6;"/></td>
                                    </tr>
                                </tbody>
                                <!--循环代码加载此处-->
                            </table>
                           &lt;%&ndash; <div class="col-sm-8 col-form-label text-left" style="margin-left: 300px;"><label >退款再充值规则：</label></div>
                            <div style="display:inline" class="col-sm-8 col-form-label text-left" >
                                <span class="col-sm-2  col-form-label text-left" style="margin-left: 300px;">退款</span>
                                &lt;%&ndash;<input type="text" class="form-control" id="countId" name="levelName" class="col-sm-4  col-form-label text-left" style="width: 10%">&ndash;%&gt;
                                <input type="text"  class="col-sm-4  col-form-label text-left" id="refundUnhandsel" name="refundUnhandsel"  style="width: 10%; border-bottom: 2px solid #666;">
                                <span class="col-sm-2  col-form-label text-left">次后,再充值不赠送权益金</span></div>&ndash;%&gt;
                        </div> -->--%>
                      <%--  <div class="form-group row" id="handselInputId" style="display:none;">
                            <label class="col-sm-3 col-form-label text-right">退款再充值规则：</label></br>
                            <div class="col-sm-8 col-sm-8" >
                                <span class="col-sm-2  col-form-label text-left" >退款</span>
                                <input type="text" id="refundUnhandsel" name="refundUnhandsel"  style="width: 10%; border-bottom: 2px solid #666;">
                                <span class="col-sm-2  col-form-label text-left">次后,再充值不赠送权益金</span>
                            </div>
                        </div>--%>
                        <div class="form-group row" id="brithdayId" style="display:none;">
                            <label class="col-sm-3 col-form-label text-right"> </label></br>
                            <div class="col-sm-8 col-sm-8" >
                                <select  name="ticketTypeId"  id="ticketTypeId" class="form-control" placeholder="选择卡券" lay-search="">
                                    <option value="" selected="selected">请选择</option>
                                    <c:forEach items="${ticketInfos}" var="info">
                                        <option value="${info.ticketTypeId}">${info.ticketName}|${info.discountTypeName}|${info.userTypeName}|${info.discountDesc}
                                        </option>
                                    </c:forEach>
                                </select>
                            </div>
                        </div>

                       <%-- <div class="form-group row" id="reliefEnum1" style="display:none;">
                            <input type="checkbox"   id="reliefEnum" name="reliefEnum" value="1" style="margin-left: 212px;">减免
                        </div>
                        <div class="form-group row" id="reliefEnum2" style="display:none;">
                            <div class="col-sm-4" style="margin-left: 300px;">
                                <input type="radio"  name="reliefType" value="1" checked>整单
                            </div>
                        </div>
                        <div class="form-group row" id="reliefEnum3"  style="display:none;">
                            <div class="col-sm-4" style="margin-left: 300px;">
                                <input type="radio"  name="reliefType" value="2">
                                满 <input type="text"  class="col-sm-4  col-form-label text-left" id="reliefFull" name="reliefFull"  style="width: 30%; border-bottom: 2px solid #666;">
                                减 <input type="text"  class="col-sm-4  col-form-label text-left" id="reliefReduce" name="reliefReduce"  style="width: 30%; border-bottom: 2px solid #666;">
                            </div>
                        </div>--%>
                        <div class="form-group row">
                            <label class="col-sm-3 col-form-label text-right">是否默认：</label>
                            <div class="col-sm-8">
                                <select class="form-control" name="isDefault" id="isDefault">
                                    <option value="0">否</option>
                                    <option value="1">是</option>
                                </select>
                            </div>
                        </div>
                        <div class="form-group row">
                            <label class="col-sm-3 col-form-label text-right">权益说明：</label>
                            <div class="col-sm-8">
                                <input type="text" class="form-control" id="gainExplain" name="gainExplain">
                            </div>
                        </div>
                        <div class="form-group row">
                            <label class="col-sm-3 col-form-label text-right">排序：</label>
                            <div class="col-sm-8">
                                <input type="text" class="form-control" id="sort" name="sort">
                            </div>
                        </div>
                        <div class="form-group row">
                            <label class="col-sm-3 col-form-label text-right">状态：</label>
                            <div class="col-sm-8">
                                <select class="form-control" name="status" id="status">
                                    <option value="0">启用</option>
                                    <option value="1">停用</option>
                                </select>
                            </div>
                        </div>

                        <div class="form-group">
                            <div class="col-sm-3 col-sm-offset-8 text-right">
                                <button type="submit" class="btn btn-primary">提交</button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
<script type="text/javascript">
    function typeChange(_val,_index){
        if (_index==2){
            $("#brithdayId").show();
            $("#consumeInputId").hide();
            $("#handselInputId").hide();
            $("#refundCountTarget").val("");
            $("#refundUnhandsel").val("");
        }else{
            if (_index==0){
                $("#consumeInputId").show();
                $("#brithdayId").hide();
                $("#handselInputId").hide();
                $("#refundUnhandsel").val("");
                $("#ticketTypeId").val("");
            }else{
                $("#handselInputId").show();
                $("#brithdayId").hide();
                $("#consumeInputId").hide();
                $("#refundCountTarget").val("");
                $("#ticketTypeId").val("");
            }
        }
        // initTable("bableId");
        // initTable("chargeHandselId");
    }



    $("#file1").change(function () {
        var objUrl = getObjectURL(this.files[0]);//获取文件信息
        var fileSize = $(this)[0].files[0].size
        if (objUrl) {
            if (fileSize > (2 * 1024 * 1024)) {
                layer.msg('请上传小于2M的图片！');
                $(this).val("");
                return
            }
            $("#gainLogo").attr("src", objUrl);
        }
    });

    function getObjectURL(file) {
        var url = null;
        if (window.createObjectURL != undefined) {
            url = window.createObjectURL(file);
        } else if (window.URL != undefined) { // mozilla(firefox)
            url = window.URL.createObjectURL(file);
        } else if (window.webkitURL != undefined) { // webkit or chrome
            url = window.webkitURL.createObjectURL(file);
        }
        return url;
    }

</script>

</body>
</html>
<script>
    addMemberGain.init();
</script>
